
#pragma once

#include <gl/glew.h>
#include <string>
#include <iostream>
#include <fstream>
using namespace std;

#include "GlobalTypes.h"


/*
http://stackoverflow.com/questions/13740147/glgetattriblocation-vs-glbindattriblocation
*/


class Shader
{
public:
	Shader(string filename, void(*bindFunc)(GLuint));

	void bind();
	void unBind();
	void applyUniform();

	GLuint getUniformLocation(const char* name)
	{
		return glGetUniformLocation(_shaderProgram, name);
	}

private:
	GLuint _shaderProgram;

	void createShaderFromFile(string filename, void(*bindFunc)(GLuint));
	bool compileShader(GLuint* shader, GLenum type, string file);
	bool linkProgram(GLuint prog);
	bool validateProgram(GLuint prog);
	GLchar* getShaderSource(string source);
};

